<!--
  智慧社区管理系统 - 404错误页面
  @author Wu.Liang
  @date 2024-01-01
-->
<template>
    <div class="error-page">
        <div class="error-container">
            <div class="error-icon">
                <el-icon size="120" color="#909399">
                    <QuestionFilled />
                </el-icon>
            </div>
            <div class="error-content">
                <h1 class="error-title">404</h1>
                <h2 class="error-subtitle">页面不存在</h2>
                <p class="error-description">
                    抱歉，您访问的页面不存在。<br>
                    请检查URL是否正确，或返回首页。
                </p>
                <div class="error-actions">
                    <el-button type="primary" @click="goBack">
                        <el-icon><ArrowLeft /></el-icon>
                        返回上一页
                    </el-button>
                    <el-button @click="goHome">
                        <el-icon><House /></el-icon>
                        返回首页
                    </el-button>
                    <el-button @click="refreshPage">
                        <el-icon><Refresh /></el-icon>
                        刷新页面
                    </el-button>
                </div>
            </div>
        </div>
    </div>
</template>

<script setup lang="ts">
/**
 * 404页面不存在错误页面
 * @author Wu.Liang
 * @date 2024-12-21
 */
import { QuestionFilled, ArrowLeft, House, Refresh } from '@element-plus/icons-vue'
import { useRouter } from 'vue-router'

const router = useRouter()

/**
 * 返回上一页
 */
const goBack = () => {
    if (window.history.length > 1) {
        router.go(-1)
    } else {
        goHome()
    }
}

/**
 * 返回首页
 */
const goHome = () => {
    router.push('/dashboard')
}

/**
 * 刷新页面
 */
const refreshPage = () => {
    window.location.reload()
}
</script>

<style scoped>
.error-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}

.error-container {
    text-align: center;
    background: white;
    border-radius: 16px;
    padding: 60px 40px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    max-width: 500px;
    width: 100%;
}

.error-icon {
    margin-bottom: 30px;
    animation: pulse 2s infinite;
}

.error-title {
    font-size: 72px;
    font-weight: bold;
    color: #909399;
    margin: 0 0 10px 0;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.error-subtitle {
    font-size: 24px;
    color: #303133;
    margin: 0 0 20px 0;
    font-weight: 600;
}

.error-description {
    font-size: 16px;
    color: #606266;
    line-height: 1.6;
    margin: 0 0 40px 0;
}

.error-actions {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
}

.error-actions .el-button {
    min-width: 120px;
    height: 40px;
    border-radius: 20px;
    font-weight: 500;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

/* 响应式设计 */
@media (max-width: 768px) {
    .error-container {
        padding: 40px 20px;
    }
    
    .error-title {
        font-size: 48px;
    }
    
    .error-subtitle {
        font-size: 20px;
    }
    
    .error-actions {
        flex-direction: column;
        align-items: center;
    }
    
    .error-actions .el-button {
        width: 200px;
    }
}
</style>
